// import { deleteTask} from '../../utils/api/module/task.js'
import {deldelmyservice} from '../../utils/api/module/task.js'
import config from "../../config";

Component({
    properties: {
        datas: {
            type: Object,
            value:'',
        }
    },
    data: {
        URL:config._URL_,
        imgs:{
            titleImg: "/assets/img/banner01.png",
            delIcon: "/assets/img/icon02@2x.png",
        }
    },
    methods: {
        _clickDelete(e){
            let id= e.currentTarget.dataset.id;
            let that = this;
            wx.showModal({
                content:'确定需要删除吗？',
                confirmColor: '#298df8',
                confirmText: '取消',
                cancelColor: '#8e8e8e',
                cancelText: '确认',
                success(res){
                    if(res.cancel){
                        //调用api 删除
                        deldelmyservice({
                            mid: wx.getStorageSync('userInfo').mid,
                            sid: id
                        },{
                            Cookie: 'SESSION_='+wx.getStorageSync('session_id'),
                        }).then(res=>{
                           if(res.data.code == 1) {
                                wx.showToast({title:`${res.data.message}`,icon:'none'})
                                that.triggerEvent('delSuccessCallback', res.data)
                           }else{
                                wx.showToast({title:`对不起，${res.data.message}，请您重试`,icon:'none'})
                           }
                        }).catch(err=>{
                            console.log(err);
                        })
                    }else if(res.confirm){
                        console.log("取消删除",id);
                    }
                },
                fail(err){
                    console.log(err);
                }
            })
        }
    },
    attached() {
        console.log(this.data);
    }
});
